#pragma once
#include<iostream>
#include<unistd.h>
#include<string.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<sys/types.h>

const std::string gpipeFile = "./fifo";
const int gdefaultid=-1;
const int gsize=1024;
const int gidforread=O_RDONLY;
const int gidforwrite=O_WRONLY;
const mode_t gmode=0600;

int OpenFife(int flag)  //flag打开方式
{
    // 如果读端打开文件时，写端还没打开，读端对用的open就会阻塞
    int fd = ::open(gpipeFile.c_str(), flag);
    if (fd < 0)
    {
        std::cerr << "open error" << std::endl;
    }
    return fd;
}

void CloseFife(int fd)
{
    if(fd>=0)
    ::close(fd);
}

